package edu.bbu.commonproject.backend.utils;

import java.io.IOException;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;

public class ServerLogger
{
	/** The logger. */
	private static Logger logger;
	
	static
	{
		logger = Logger.getLogger("ServerLogger");
		
		try
		{
			FileHandler fileHandler = new FileHandler("log/log_file.txt");
			fileHandler.setFormatter(new SimpleFormatter());
			
			logger.setLevel(Level.ALL);
			logger.addHandler(fileHandler);
			//logger.setUseParentHandlers(false);
		    
		    
		}
		catch (SecurityException | IOException e)
		{
			System.err.println("Server logget failed to initialize.");
		}
	}
	
	/**
	 * Logging a message.
	 * @param level the log level.
	 * @param message the log message.
	 */
	public static void log(Level level, String message)
	{
		logger.log(level, message);
	}
}
